home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 November / Maximum CD 2000 Nov.iso / AofE-Conquerers / age2xtrial.exe / CABFILE / MSGAME.CAB / Data / gamedata_x1.drs / Unnamed File 000005.bina < prev    next >
Text File  |  2000-07-18  |  50KB  |  2,391 lines

  1. ;start the run-through
  2. (defrule
  3.     (true)
  4. =>
  5.     (set-goal infantry-upgrades NO)
  6.     (set-goal archer-upgrades NO)
  7.     (set-goal cav-upgrades NO)
  8. )
  9.  
  10. ;infantry civs
  11. (defrule
  12.     (soldier-count >= five-percent-pop)
  13.     (or
  14.         (or
  15.             (goal combat-arm INFANTRY)
  16.             (goal combat-supp INFANTRY)
  17.         )
  18.         (goal pre-unique-arm INFANTRY)
  19.     )
  20. =>
  21.     (set-goal infantry-upgrades YES)
  22. )
  23.  
  24. (defrule
  25.     (building-type-count castle > 0)
  26.     (soldier-count >= five-percent-pop)
  27.     (or
  28.         (or
  29.             (civ-selected celtic)
  30.             (civ-selected frankish)
  31.         )
  32.         (or
  33.             (civ-selected aztec)
  34.             (or
  35.                 (or
  36.                     (civ-selected gothic)
  37.                     (civ-selected japanese)
  38.                 )
  39.                 (or
  40.                     (civ-selected teutonic)
  41.                     (civ-selected viking)
  42.                 )
  43.             )
  44.         )
  45.     )
  46. =>
  47.     (set-goal infantry-upgrades YES)
  48. )
  49.  
  50. ;archer civs
  51. (defrule
  52.     (soldier-count >= five-percent-pop)
  53.     (or
  54.         (or
  55.             (goal combat-arm CAVARCHER)
  56.             (goal combat-arm ARCHER)
  57.         )
  58.         (or
  59.             (or
  60.                 (goal combat-supp CAVARCHER)
  61.                 (goal combat-supp ARCHER)
  62.             )
  63.             (or
  64.                 (goal pre-unique-arm CAVARCHER)
  65.                 (goal pre-unique-arm ARCHER)
  66.             )
  67.         )
  68.     )
  69. =>
  70.     (set-goal archer-upgrades YES)
  71. )
  72.  
  73. (defrule
  74.     (building-type-count castle > 0)
  75.     (soldier-count >= five-percent-pop)
  76.     (or
  77.         (or
  78.             (civ-selected korean)
  79.             (or
  80.                 (civ-selected mayan)
  81.                 (civ-selected spanish)
  82.             )
  83.         )
  84.         (or
  85.             (or
  86.                 (civ-selected briton)
  87.                 (civ-selected chinese)
  88.             )
  89.             (or
  90.                 (civ-selected mongol)
  91.                 (civ-selected turkish)
  92.             )
  93.         )
  94.     )
  95. =>
  96.     (set-goal archer-upgrades YES)
  97. )
  98.  
  99. ;cav civs
  100. (defrule
  101.     (soldier-count >= five-percent-pop)
  102.     (or
  103.         (goal pre-unique-arm CAVALRY)
  104.         (or
  105.             (or
  106.                 (goal combat-arm CAVALRY)
  107.                 (goal combat-arm LIGHTCAV)
  108.             )
  109.             (or
  110.                 (goal combat-supp CAVALRY)
  111.                 (goal combat-supp LIGHTCAV)
  112.             )
  113.         )
  114.     )
  115. =>
  116.     (set-goal cav-upgrades YES)
  117. )
  118.  
  119. (defrule
  120.     (building-type-count castle > 0)
  121.     (soldier-count >= five-percent-pop)
  122.     (or
  123.         (or
  124.             (civ-selected byzantine)
  125.             (civ-selected persian)
  126.         )
  127.         (or
  128.             (civ-selected hun)
  129.             (civ-selected saracen)
  130.         )
  131.     )
  132. =>
  133.     (set-goal cav-upgrades YES)
  134. )
  135.  
  136. ;*************************************************
  137. (defrule
  138.     (or
  139.         (current-age >= feudal-age)
  140.         (goal upgrade-conflict NOTICE)
  141.     )
  142. =>
  143.     (set-escrow-percentage wood 50)
  144.     (set-escrow-percentage food 50)
  145.     (set-escrow-percentage gold 50)
  146.     (set-escrow-percentage stone 50)
  147. )
  148.  
  149. (defrule
  150.     (current-age > feudal-age)
  151.     (difficulty <= moderate)
  152.     (building-type-count-total town-center < 2)
  153.     (or
  154.         (building-type-count-total castle > 0)
  155.         (goal castle-attempt 0)
  156.     )
  157. =>
  158.     (set-escrow-percentage wood 70)
  159.     (set-escrow-percentage stone 100)
  160. )
  161.  
  162. ;********************************************
  163. (defrule
  164.     (true)
  165. =>
  166.     (generate-random-number 31000)
  167. )
  168.  
  169. (defrule
  170.     (goal upgrade-conflict NO)
  171.     (current-age >= feudal-age)
  172.     (current-age-time > 300)
  173.     (nor
  174.         (goal rush-control CASTLE)
  175.         (goal rush-control IMPERIAL)
  176.     )
  177. =>
  178.     (generate-random-number 47)
  179. )
  180.  
  181. (defrule
  182.     (difficulty <= moderate)
  183.     (food-amount >= 400)
  184.     (gold-amount >= 400)
  185.     (building-type-count castle > 0)
  186.     (unit-type-count my-unique-unit > five-percent-pop)
  187.     (or
  188.         (research-available my-unique-unit-upgrade)
  189.         (research-available ri-elite-longboat)
  190.     )
  191.     (not (goal upgrade-conflict NOTICE) )
  192. =>
  193.     (set-goal upgrade-conflict 90)
  194.     (set-goal resource-supp FOOD-GOLD)
  195. )
  196.  
  197. (defrule
  198.     (goal upgrade-conflict 90)
  199.     (can-research-with-escrow my-unique-unit-upgrade)
  200. =>
  201.     (release-escrow food)
  202.     (release-escrow gold)
  203.     (research my-unique-unit-upgrade)
  204.     (set-goal upgrade-conflict NO)
  205. )
  206.  
  207. (defrule    ;750 food, 475 gold
  208.     (goal upgrade-conflict 90)
  209.     (unit-type-count my-unique-unit < five-percent-pop)
  210.     (unit-type-count-total longboat > 2)
  211.     (can-research-with-escrow ri-elite-longboat)
  212. =>
  213.     (release-escrow food)
  214.     (release-escrow gold)
  215.     (research ri-elite-longboat)
  216.     (set-goal resource-supp NO)
  217. )
  218.  
  219. (defrule
  220.     (goal upgrade-conflict NO)
  221.     (difficulty <= hard)
  222.     (building-type-count castle > 0)
  223. =>
  224.     (set-goal upgrade-conflict 94)
  225. )
  226.  
  227. (defrule
  228.     (goal upgrade-conflict 94)
  229.     (or
  230.         (or
  231.             (civ-selected aztec)
  232.             (civ-selected celtic)
  233.         )
  234.         (or
  235.             (civ-selected gothic)
  236.             (civ-selected persian)
  237.         )
  238.     )
  239. =>
  240.     (set-goal upgrade-conflict 95)
  241.     (set-goal resource-supp FOOD-GOLD)
  242. )
  243.  
  244. (defrule
  245.     (goal upgrade-conflict 94)
  246.     (or
  247.         (or
  248.             (civ-selected saracen)
  249.             (civ-selected spanish)
  250.         )
  251.         (or
  252.             (civ-selected viking)
  253.             (civ-selected korean)
  254.         )
  255.     )
  256. =>
  257.     (set-goal upgrade-conflict 95)
  258.     (set-goal resource-supp FOOD-GOLD)
  259. )
  260.  
  261. (defrule
  262.     (goal upgrade-conflict 94)
  263.     (civ-selected chinese)
  264. =>
  265.     (set-goal upgrade-conflict 95)
  266.     (set-goal resource-supp WOOD-GOLD)
  267. )
  268.  
  269. (defrule
  270.     (goal upgrade-conflict 94)
  271.     (civ-selected briton)
  272.     (research-completed ri-bracer)
  273. =>
  274.     (set-goal upgrade-conflict 95)
  275.     (set-goal resource-supp WOOD-GOLD)
  276. )
  277.  
  278. (defrule
  279.     (goal upgrade-conflict 94)
  280.     (civ-selected byzantine)
  281. =>
  282.     (set-goal upgrade-conflict 95)
  283.     (set-goal resource-supp FOOD-GOLD)
  284. )
  285.  
  286. (defrule
  287.     (goal upgrade-conflict 94)
  288.     (civ-selected frankish)
  289.     (or
  290.         (or
  291.             (cc-players-unit-type-count any-enemy archer-line >= 6)
  292.             (cc-players-unit-type-count any-enemy chu-ko-nu-line >= 6)
  293.         )
  294.         (or
  295.             (or
  296.                 (cc-players-unit-type-count any-enemy janissary-line >= 6)
  297.                 (cc-players-unit-type-count any-enemy longbowman-line >= 6)
  298.             )
  299.             (cc-players-unit-type-count any-enemy mangudai-line >= 6)
  300.         )
  301.     )
  302. =>
  303.     (set-goal upgrade-conflict 95)
  304.     (set-goal resource-supp FOOD-GOLD)
  305. )
  306.  
  307. (defrule
  308.     (goal upgrade-conflict 94)
  309.     (civ-selected hun)
  310.     (cc-players-building-type-count any-enemy wonder > 0)
  311. =>
  312.     (set-goal upgrade-conflict 95)
  313.     (set-goal resource-supp FOOD-GOLD)
  314. )
  315.  
  316. (defrule
  317.     (goal upgrade-conflict 94)
  318.     (building-type-count siege-workshop > 0)
  319.     (or
  320.         (civ-selected japanese)
  321.         (civ-selected mongol)
  322.     )
  323. =>
  324.     (set-goal upgrade-conflict 95)
  325.     (set-goal resource-supp FOOD-GOLD)
  326. )
  327.  
  328. (defrule
  329.     (goal upgrade-conflict 94)
  330.     (civ-selected mayan)
  331.     (goal combat-supp EAGLEMAN)
  332. =>
  333.     (set-goal upgrade-conflict 95)
  334.     (set-goal resource-supp FOOD-GOLD)
  335. )
  336.  
  337. (defrule
  338.     (goal upgrade-conflict 94)
  339.     (civ-selected turkish)
  340.     (or
  341.         (or
  342.             (unit-type-count-total cannon-galleon-line > 3)
  343.             (unit-type-count-total bombard-cannon > 3)
  344.         )
  345.         (unit-type-count-total bombard-tower > 3)
  346.     )
  347. =>
  348.     (set-goal upgrade-conflict 95)
  349.     (set-goal resource-supp FOOD-STONE)
  350. )
  351.  
  352. (defrule
  353.     (goal upgrade-conflict 94)
  354. =>
  355.     (set-goal upgrade-conflict NO)
  356. )
  357.  
  358. (defrule
  359.     (goal upgrade-conflict 95)
  360.     (can-research-with-escrow my-unique-research)
  361. =>
  362.     (release-escrow wood)
  363.     (release-escrow food)
  364.     (release-escrow gold)
  365.     (release-escrow stone)
  366.     (research my-unique-research)
  367.     (set-goal upgrade-conflict NO)
  368. )
  369.  
  370. ;*************
  371. ;TOWN CENTER RESEARCH
  372. (defrule    ;50 gold
  373.     (can-research ri-loom)
  374.     (or
  375.         (not (can-train villager) )
  376.         (civilian-population > 7)
  377.     )
  378. =>
  379.     (research ri-loom)
  380. )
  381.  
  382. (defrule    ;75 food
  383.     (goal upgrade-conflict NO)
  384.     (random-number <= 2)
  385.     (building-type-count town-center > 0)
  386.     (research-available ri-town-watch)
  387.     (or
  388.         (goal age-advancement NOTICE)
  389.         (food-amount > 700)
  390.     )
  391. =>
  392.     (set-goal upgrade-conflict 2)
  393.     (set-goal resource-supp FOOD-ONLY)
  394. )
  395.  
  396. (defrule    ;300 food, 200 gold
  397.     (goal upgrade-conflict NO)
  398.     (current-age == imperial-age)
  399.     (random-number <= 2)
  400.     (building-type-count town-center > 0)
  401.     (research-available ri-town-patrol)
  402.     (or
  403.         (difficulty > moderate)
  404.         (building-type-count town-center > 1)
  405.     )
  406. =>
  407.     (set-goal upgrade-conflict 2)
  408.     (set-goal resource-supp FOOD-GOLD)
  409. )
  410.  
  411. (defrule
  412.     (goal upgrade-conflict 2)
  413.     (can-research-with-escrow ri-town-watch)
  414. =>
  415.     (release-escrow food)
  416.     (research ri-town-watch)
  417.     (set-goal upgrade-conflict NO)
  418. )
  419.  
  420. (defrule
  421.     (goal upgrade-conflict 2)
  422.     (can-research-with-escrow ri-town-patrol)
  423. =>
  424.     (release-escrow food)
  425.     (release-escrow gold)
  426.     (research ri-town-patrol)
  427.     (set-goal upgrade-conflict NO)
  428. )
  429.  
  430. (defrule    ;50 wood, 175 food
  431.     (difficulty <= moderate)
  432.     (can-research-with-escrow ri-wheel-barrow)
  433.     (current-age >= castle-age)
  434.     (or
  435.         (difficulty > moderate)
  436.         (building-type-count town-center > 1)
  437.     )
  438.     (nor
  439.         (goal upgrade-conflict NOTICE)
  440.         (or
  441.             (can-research ri-wheel-barrow)
  442.             (goal rush-control IMPERIAL)
  443.         )
  444.     )
  445. =>
  446.     (release-escrow wood)
  447.     (release-escrow food)
  448.     (research ri-wheel-barrow)
  449. )
  450.  
  451. (defrule
  452.     (difficulty <= moderate)
  453.     (can-research ri-wheel-barrow)
  454.     (nor 
  455.         (goal upgrade-conflict NOTICE)
  456.         (goal rush-control IMPERIAL)
  457.     )
  458.     (current-age >= castle-age)
  459. =>
  460.     (research ri-wheel-barrow)
  461. )
  462.  
  463. (defrule    ;200 wood, 300 food
  464.     (civilian-population >= civ-castle)
  465.     (difficulty <= hard)
  466.     (can-research-with-escrow ri-hand-cart)
  467.     (or
  468.         (difficulty > moderate)
  469.         (building-type-count town-center > 1)
  470.     )
  471.     (nor
  472.         (goal upgrade-conflict NOTICE)
  473.         (or
  474.             (can-research ri-hand-cart)
  475.             (goal rush-control IMPERIAL)
  476.         )
  477.     )
  478. =>
  479.     (release-escrow wood)
  480.     (release-escrow food)
  481.     (research ri-hand-cart)
  482. )
  483.  
  484. (defrule
  485.     (civilian-population >= civ-castle)
  486.     (difficulty <= hard)
  487.     (can-research ri-hand-cart)
  488.     (nor
  489.         (goal upgrade-conflict NOTICE)
  490.         (goal rush-control IMPERIAL)
  491.     )
  492. =>
  493.     (research ri-hand-cart)
  494. )
  495.  
  496. ;*************
  497. ;MINING-CAMP
  498. (defrule    ;75 wood, 100 food
  499.     (goal upgrade-conflict NO)
  500.     (difficulty <= moderate)
  501.     (random-number <= 3)
  502.     (civilian-population >= civ-castle)
  503.     (building-type-count mining-camp > 1)
  504.     (research-completed ri-gold-mining)
  505.     (research-available ri-stone-mining)
  506. =>
  507.     (set-goal upgrade-conflict 3)
  508.     (set-goal resource-supp WOOD-FOOD)
  509. )
  510.  
  511. (defrule    ;150 wood, 200 food
  512.     (goal upgrade-conflict NO)
  513.     (goal resource-needed STONE)
  514.     (difficulty <= hard)
  515.     (random-number <= 3)
  516.     (civilian-population >= civ-castle)
  517.     (building-type-count mining-camp > 0)
  518.     (research-completed ri-gold-shaft-mining)
  519.     (research-available ri-stone-shaft-mining)
  520. =>
  521.     (set-goal upgrade-conflict 3)
  522.     (set-goal resource-supp WOOD-FOOD)
  523. )
  524.  
  525. (defrule
  526.     (goal upgrade-conflict 3)
  527.     (or
  528.         (can-research-with-escrow ri-stone-mining)
  529.         (can-research-with-escrow ri-stone-shaft-mining)
  530.     )
  531. =>
  532.     (release-escrow wood)
  533.     (release-escrow food)
  534.     (research ri-stone-mining)
  535.     (research ri-stone-shaft-mining)
  536.     (set-goal upgrade-conflict NO)
  537. )
  538.  
  539. (defrule    ;75 wood, 100 food
  540.     (goal upgrade-conflict NO)
  541.     (difficulty <= moderate)
  542.     (current-age > feudal-age)
  543.     (random-number <= 4)
  544.     (civilian-population >= civ-castle)
  545.     (building-type-count mining-camp > 0)
  546.     (research-available ri-gold-mining)
  547. =>
  548.     (set-goal upgrade-conflict 4)
  549.     (set-goal resource-supp WOOD-FOOD)
  550. )
  551.  
  552. (defrule    ;150 wood, 200 food
  553.     (goal upgrade-conflict NO)
  554.     (difficulty <= hard)
  555.     (random-number <= 4)
  556.     (civilian-population >= civ-castle)
  557.     (building-type-count mining-camp > 0)
  558.     (research-available ri-gold-shaft-mining)
  559. =>
  560.     (set-goal upgrade-conflict 4)
  561.     (set-goal resource-supp WOOD-FOOD)
  562. )
  563.  
  564. (defrule
  565.     (goal upgrade-conflict 4)
  566.     (or
  567.         (can-research-with-escrow ri-gold-mining)
  568.         (can-research-with-escrow ri-gold-shaft-mining)
  569.     )
  570. =>
  571.     (release-escrow wood)
  572.     (release-escrow food)
  573.     (research ri-gold-mining)
  574.     (research ri-gold-shaft-mining)
  575.     (set-goal upgrade-conflict NO)
  576. )
  577. ;*************
  578. ;LUMBER-CAMP
  579. (defrule    ;50 wood, 100 food
  580.     (goal upgrade-conflict NO)
  581.     (difficulty <= moderate)
  582.     (random-number <= 5)
  583.     (building-type-count lumber-camp > 0)
  584.     (research-available ri-double-bit-axe)
  585.     (or
  586.         (current-age > feudal-age)
  587.         (goal age-advancement NOTICE)
  588.     )
  589. =>
  590.     (set-goal upgrade-conflict 5)
  591.     (set-goal resource-supp WOOD-FOOD)
  592. )
  593.  
  594. (defrule    ;100 wood, 150 food
  595.     (goal upgrade-conflict NO)
  596.     (difficulty <= moderate)
  597.     (random-number <= 5)
  598.     (civilian-population >= civ-castle)
  599.     (building-type-count lumber-camp > 0)
  600.     (research-available ri-bow-saw)
  601. =>
  602.     (set-goal upgrade-conflict 5)
  603.     (set-goal resource-supp WOOD-FOOD)
  604. )
  605.  
  606. (defrule    ;200 wood, 300 food
  607.     (goal upgrade-conflict NO)
  608.     (difficulty <= hard)
  609.     (random-number <= 5)
  610.     (civilian-population >= civ-castle)
  611.     (building-type-count lumber-camp > 0)
  612.     (research-available ri-two-man-saw)
  613. =>
  614.     (set-goal upgrade-conflict 5)
  615.     (set-goal resource-supp WOOD-FOOD)
  616. )
  617.  
  618. (defrule
  619.     (goal upgrade-conflict 5)
  620.     (or
  621.         (can-research-with-escrow ri-double-bit-axe)
  622.         (or
  623.             (can-research-with-escrow ri-bow-saw)
  624.             (can-research-with-escrow ri-two-man-saw)
  625.         )
  626.     )
  627. =>
  628.     (release-escrow wood)
  629.     (release-escrow food)
  630.     (research ri-double-bit-axe)
  631.     (research ri-bow-saw)
  632.     (research ri-two-man-saw)
  633.     (set-goal upgrade-conflict NO)
  634. )
  635. ;*************
  636. ;DOCK
  637. (defrule    ;200 wood, 300 gold
  638.     (goal upgrade-conflict NO)
  639.     (difficulty <= hard)
  640.     (random-number <= 6)
  641.     (building-type-count dock > 0)
  642.     (research-available ri-heavy-demolition-ship)
  643.     (not (goal 1 0) )
  644. =>
  645.     (set-goal upgrade-conflict 6)
  646.     (set-goal resource-supp WOOD-GOLD)
  647. )
  648.  
  649. (defrule
  650.     (goal upgrade-conflict 6)
  651.     (can-research-with-escrow ri-heavy-demolition-ship)
  652. =>
  653.     (release-escrow wood)
  654.     (release-escrow gold)
  655.     (research ri-heavy-demolition-ship)
  656.     (set-goal upgrade-conflict NO)
  657. )
  658.  
  659. (defrule    ;600 food, 400 gold
  660.     (goal upgrade-conflict NO)
  661.     (building-type-count dock > 0)
  662.     (research-available ri-dry-dock)
  663.     (random-number <= 7)
  664.     (not (goal 1 0) )
  665. =>
  666.     (set-goal upgrade-conflict 7)
  667.     (set-goal resource-supp FOOD-GOLD)
  668. )
  669.  
  670. (defrule
  671.     (goal upgrade-conflict 7)
  672.     (can-research-with-escrow ri-dry-dock)
  673. =>
  674.     (release-escrow food)
  675.     (release-escrow gold)
  676.     (research ri-dry-dock)
  677.     (set-goal upgrade-conflict NO)
  678. )
  679.  
  680. (defrule    ;1000 food, 300 gold
  681.     (goal upgrade-conflict NO)
  682.     (building-type-count dock > 0)
  683.     (research-available ri-shipwright)
  684.     (warboat-count > five-percent-pop)
  685.     (random-number <= 8)
  686. =>
  687.     (set-goal upgrade-conflict 8)
  688.     (set-goal resource-supp FOOD-GOLD)
  689. )
  690.  
  691. (defrule
  692.     (goal upgrade-conflict 8)
  693.     (can-research-with-escrow ri-shipwright)
  694. =>
  695.     (release-escrow food)
  696.     (release-escrow gold)
  697.     (research ri-shipwright)
  698.     (set-goal upgrade-conflict NO)
  699. )
  700.  
  701. (defrule    ;250 food, 150 gold
  702.     (building-type-count dock > 0)
  703.     (can-research-with-escrow ri-careening)
  704.     (not (goal rush-control IMPERIAL) )
  705.     (nor
  706.         (goal 1 0)
  707.         (can-research ri-careening)
  708.     )
  709. =>
  710.     (release-escrow food)
  711.     (release-escrow gold)
  712.     (research ri-careening)
  713. )
  714.  
  715. (defrule
  716.     (building-type-count dock > 0)
  717.     (can-research ri-careening)
  718.     (nor
  719.         (goal 1 0) 
  720.         (goal rush-control IMPERIAL)
  721.     )
  722. =>
  723.     (research ri-careening)
  724. )
  725.  
  726. (defrule    ;280 wood, 250 gold
  727.     (building-type-count dock > 0)
  728.     (unit-type-count-total fire-ship-line > 1)
  729.     (can-research-with-escrow ri-fast-fire-ship)
  730.     (nor
  731.         (goal 1 0)
  732.         (can-research ri-fast-fire-ship)
  733.     )
  734. =>
  735.     (release-escrow wood)
  736.     (release-escrow gold)
  737.     (research ri-fast-fire-ship)
  738. )
  739.  
  740. (defrule
  741.     (building-type-count dock > 0)
  742.     (unit-type-count-total fire-ship-line > 1)
  743.     (can-research ri-fast-fire-ship)
  744.     (not (goal 1 0) )
  745. =>
  746.     (research ri-fast-fire-ship)
  747. )
  748.  
  749. (defrule    ;500 wood, 400 food
  750.     (difficulty <= moderate)
  751.     (building-type-count dock > 0)
  752.     (can-research-with-escrow ri-cannon-galleon)
  753.     (nor
  754.         (goal 1 0)
  755.         (can-research ri-cannon-galleon)
  756.     )
  757. =>
  758.     (release-escrow wood)
  759.     (release-escrow food)
  760.     (research ri-cannon-galleon)
  761. )
  762.  
  763. (defrule
  764.     (difficulty <= moderate)
  765.     (building-type-count dock > 0)
  766.     (can-research ri-cannon-galleon)
  767.     (not (goal 1 0) )
  768. =>
  769.     (research ri-cannon-galleon)
  770. )
  771.  
  772. (defrule    ;525 wood, 500 gold
  773.     (difficulty <= hard)
  774.     (building-type-count dock > 0)
  775.     (unit-type-count-total cannon-galleon > 0)
  776.     (can-research-with-escrow ri-deck-guns)
  777.     (not (can-research ri-deck-guns) )
  778. =>
  779.     (release-escrow wood)
  780.     (release-escrow gold)
  781.     (research ri-deck-guns)
  782. )
  783.  
  784. (defrule
  785.     (difficulty <= hard)
  786.     (building-type-count dock > 0)
  787.     (unit-type-count-total cannon-galleon > 0)
  788.     (can-research ri-deck-guns)
  789. =>
  790.     (research ri-deck-guns)
  791. )
  792.  
  793. (defrule    ;230 food, 100 gold
  794.     (building-type-count dock > 0)
  795.     (unit-type-count-total galley-line > 1)
  796.     (can-research-with-escrow ri-war-galley)
  797.     (nand
  798.         (civ-selected viking)
  799.         (building-type-count-total castle > 0)
  800.     )
  801.     (nor
  802.         (goal 1 0)
  803.         (or
  804.             (can-research ri-war-galley)
  805.             (goal rush-control IMPERIAL)
  806.         )
  807.     )
  808. =>
  809.     (release-escrow food)
  810.     (release-escrow gold)
  811.     (research ri-war-galley)
  812. )
  813.  
  814. (defrule
  815.     (building-type-count dock > 0)
  816.     (unit-type-count-total galley-line > 1)
  817.     (can-research ri-war-galley)
  818.     (nand
  819.         (civ-selected viking)
  820.         (building-type-count-total castle > 0)
  821.     )
  822.     (nor
  823.         (goal 1 0)
  824.         (goal rush-control IMPERIAL)
  825.     )
  826. =>
  827.     (research ri-war-galley)
  828. )
  829.  
  830. (defrule    ;315 wood, 400 food
  831.     (building-type-count dock > 0)
  832.     (can-research-with-escrow ri-galleon)
  833.     (nand
  834.         (civ-selected viking)
  835.         (building-type-count-total castle > 0)
  836.     )
  837.     (nor
  838.         (goal 1 0)
  839.         (can-research ri-galleon)
  840.     )
  841. =>
  842.     (release-escrow wood)
  843.     (release-escrow food)
  844.     (research ri-galleon)
  845. )
  846.  
  847. (defrule
  848.     (building-type-count dock > 0)
  849.     (can-research ri-galleon)
  850.     (nand
  851.         (civ-selected viking)
  852.         (building-type-count-total castle > 0)
  853.     )
  854.     (not (goal 1 0) )
  855. =>
  856.     (research ri-galleon)
  857. )
  858.  
  859.  
  860. ;*************
  861. ;MILL
  862. (defrule    ;75 wood, 75 food
  863.     (goal upgrade-conflict NO)
  864.     (difficulty <= moderate)
  865.     (random-number <= 9)
  866.     (building-type-count-total farm >= 8)
  867.     (building-type-count mill > 0)
  868.     (research-available ri-horse-collar)
  869.     (current-age-time > 30)
  870.     (or
  871.         (current-age > feudal-age)
  872.         (goal age-advancement NOTICE)
  873.     )
  874.     (not (goal rush-control IMPERIAL) )
  875. =>
  876.     (set-goal upgrade-conflict 9)
  877.     (set-goal resource-supp WOOD-FOOD)
  878. )
  879.  
  880. (defrule    ;125 wood, 125 food
  881.     (goal upgrade-conflict NO)
  882.     (difficulty <= moderate)
  883.     (random-number <= 9)
  884.     (building-type-count-total farm >= 10)
  885.     (building-type-count mill > 0)
  886.     (research-available ri-heavy-plow)
  887. =>
  888.     (set-goal upgrade-conflict 9)
  889.     (set-goal resource-supp WOOD-FOOD)
  890. )
  891.  
  892. (defrule    ;250 wood, 250 food
  893.     (goal upgrade-conflict NO)
  894.     (difficulty <= hard)
  895.     (random-number <= 9)
  896.     (building-type-count-total farm >= 12)
  897.     (building-type-count mill > 0)
  898.     (research-available ri-crop-rotation)
  899. =>
  900.     (set-goal upgrade-conflict 9)
  901.     (set-goal resource-supp WOOD-FOOD)
  902. )
  903.  
  904. (defrule
  905.     (goal upgrade-conflict 9)
  906.     (or
  907.         (can-research-with-escrow ri-horse-collar)
  908.         (or
  909.             (can-research-with-escrow ri-heavy-plow)
  910.             (can-research-with-escrow ri-crop-rotation)
  911.         )
  912.     )
  913. =>
  914.     (release-escrow wood)
  915.     (release-escrow food)
  916.     (research ri-horse-collar)
  917.     (research ri-heavy-plow)
  918.     (research ri-crop-rotation)
  919.     (set-goal upgrade-conflict NO)
  920. )
  921.  
  922. ;*************
  923. ;MARKET
  924. (defrule
  925.     (can-research ri-caravan)
  926.     (not (goal rush-control IMPERIAL) )
  927.     (or
  928.         (unit-type-count-total trade-cart > 0)
  929.         (unit-type-count-total trade-cog > 0)
  930.     )
  931. =>
  932.     (research ri-caravan)
  933. )
  934.  
  935. (defrule    ;150 food, 50 gold
  936.     (goal upgrade-conflict NO)
  937.     (difficulty <= moderate)
  938.     (random-number <= 10)
  939.     (player-in-game any-ally)
  940.     (building-type-count market > 0)
  941.     (research-available ri-coinage)
  942.     (or
  943.         (current-age > feudal-age)
  944.         (goal age-advancement NOTICE)
  945.     )
  946.     (not (goal rush-control IMPERIAL) )
  947. =>
  948.     (set-goal upgrade-conflict 10)
  949.     (set-goal resource-supp FOOD-GOLD)
  950. )
  951.  
  952. (defrule    ;200 food, 100 gold
  953.     (goal upgrade-conflict NO)
  954.     (difficulty <= moderate)
  955.     (random-number <= 10)
  956.     (player-in-game any-ally)
  957.     (building-type-count market > 0)
  958.     (research-available ri-banking)
  959. =>
  960.     (set-goal upgrade-conflict 10)
  961.     (set-goal resource-supp FOOD-GOLD)
  962. )
  963.  
  964. (defrule
  965.     (goal upgrade-conflict 10)
  966.     (or
  967.         (can-research-with-escrow ri-coinage)
  968.         (can-research-with-escrow ri-banking)
  969.     )
  970. =>
  971.     (release-escrow food)
  972.     (release-escrow gold)
  973.     (research ri-coinage)
  974.     (research ri-banking)
  975.     (set-goal upgrade-conflict NO)
  976. )
  977.  
  978. (defrule    ;100 food, 100 gold
  979.     (player-in-game any-ally)
  980.     (building-type-count market > 0)
  981.     (can-research-with-escrow ri-cartography)
  982.     (not (goal rush-control IMPERIAL) )
  983.     (or
  984.         (current-age > feudal-age)
  985.         (or
  986.             (goal age-advancement NOTICE)
  987.             (gold-amount > 300)
  988.         )
  989.     )
  990. =>
  991.     (release-escrow food)
  992.     (release-escrow gold)
  993.     (research ri-cartography)
  994. )
  995.  
  996. (defrule    ;300 food, 200 gold
  997.     (can-research-with-escrow ri-guilds)
  998.     (not (goal rush-control IMPERIAL) )
  999. =>
  1000.     (release-escrow food)
  1001.     (release-escrow gold)
  1002.     (research ri-guilds)
  1003. )
  1004. ;*************
  1005. ;BARRACKS
  1006. (defrule    ;75 food
  1007.     (goal upgrade-conflict NO)
  1008.     (goal infantry-upgrades YES)
  1009.     (random-number <= 11)
  1010.     (research-available ri-tracking)
  1011.     (or
  1012.         (current-age > feudal-age)
  1013.         (goal age-advancement NOTICE)
  1014.     )
  1015. =>
  1016.     (set-goal upgrade-conflict 11)
  1017.     (set-goal resource-supp FOOD-ONLY)
  1018. )
  1019.  
  1020. (defrule
  1021.     (goal upgrade-conflict 11)
  1022.     (can-research-with-escrow ri-tracking)
  1023. =>
  1024.     (release-escrow food)
  1025.     (research ri-tracking)
  1026.     (set-goal upgrade-conflict NO)
  1027. )
  1028.  
  1029. (defrule    ;750 food, 350 gold
  1030.     (goal upgrade-conflict NO)
  1031.     (building-type-count barracks > 0)
  1032.     (research-available ri-champion)
  1033.     (random-number <= 12)
  1034.     (goal combat-arm INFANTRY)
  1035. =>
  1036.     (set-goal upgrade-conflict 12)
  1037.     (set-goal resource-supp FOOD-GOLD)
  1038. )
  1039.  
  1040. (defrule
  1041.     (goal upgrade-conflict 12)
  1042.     (can-research-with-escrow ri-champion)
  1043. =>
  1044.     (release-escrow food)
  1045.     (release-escrow gold)
  1046.     (research ri-champion)
  1047.     (set-goal upgrade-conflict NO)
  1048. )
  1049.  
  1050. (defrule    ;200 food
  1051.     (goal upgrade-conflict NO)
  1052.     (goal infantry-upgrades YES)
  1053.     (building-type-count barracks > 0)
  1054.     (research-available ri-squires)
  1055.     (random-number <= 13)
  1056. =>
  1057.     (set-goal upgrade-conflict 13)
  1058.     (set-goal resource-supp FOOD-ONLY)
  1059. )
  1060.  
  1061. (defrule
  1062.     (goal upgrade-conflict 13)
  1063.     (can-research-with-escrow ri-squires)
  1064. =>
  1065.     (release-escrow food)
  1066.     (research ri-squires)
  1067.     (set-goal upgrade-conflict NO)
  1068. )
  1069.  
  1070. (defrule    ;215 food, 90 gold
  1071.     (unit-type-count spearman > 2)
  1072.     (can-research-with-escrow ri-pikeman)
  1073.     (or
  1074.         (goal upgrade-conflict NO)
  1075.         (current-age == imperial-age)
  1076.     )
  1077.     (nor
  1078.         (goal upgrade-conflict NOTICE)
  1079.         (or
  1080.             (can-research ri-pikeman)
  1081.             (goal rush-control IMPERIAL)
  1082.         )
  1083.     )
  1084. =>
  1085.     (release-escrow food)
  1086.     (release-escrow gold)
  1087.     (research ri-pikeman)
  1088. )
  1089.  
  1090. (defrule
  1091.     (unit-type-count spearman > 2)
  1092.     (can-research ri-pikeman)
  1093.     (or
  1094.         (goal upgrade-conflict NO)
  1095.         (current-age == imperial-age)
  1096.     )
  1097.     (nor
  1098.         (goal upgrade-conflict NOTICE) 
  1099.          (goal rush-control IMPERIAL)
  1100.     )
  1101. =>
  1102.     (research ri-pikeman)
  1103. )
  1104.  
  1105. (defrule ; food, gold
  1106.     (goal upgrade-conflict NO)
  1107.     (unit-type-count pikeman > 4)
  1108.     (random-number <= 14)
  1109.     (research-available ri-halberdier)
  1110. =>
  1111.     (set-goal upgrade-conflict 14)
  1112.     (set-goal resource-supp FOOD-GOLD)
  1113. )
  1114.  
  1115. (defrule
  1116.     (goal upgrade-conflict 14)
  1117.     (can-research-with-escrow ri-halberdier)
  1118. =>
  1119.     (release-escrow food)
  1120.     (release-escrow gold)
  1121.     (research ri-halberdier)
  1122.     (set-goal upgrade-conflict NO)
  1123. )
  1124.  
  1125.  
  1126. (defrule    ;100 food, 40 goldman-at-arms
  1127.     (can-research-with-escrow ri-man-at-arms)
  1128.     (or
  1129.         (current-age > feudal-age)
  1130.         (goal age-advancement NOTICE)
  1131.     )
  1132.     (or
  1133.         (or
  1134.             (goal combat-arm INFANTRY)
  1135.             (goal combat-supp INFANTRY)
  1136.         )
  1137.         (goal pre-unique-arm INFANTRY)
  1138.     )
  1139. =>
  1140.     (release-escrow food)
  1141.     (release-escrow gold)
  1142.     (research ri-man-at-arms)
  1143. )
  1144.  
  1145. (defrule    ;200 food, 65 gold
  1146.     (can-research-with-escrow ri-long-swordsman)
  1147.     (not (goal rush-control IMPERIAL) )
  1148.     (or
  1149.         (or
  1150.             (goal combat-arm INFANTRY)
  1151.             (goal combat-supp INFANTRY)
  1152.         )
  1153.         (goal pre-unique-arm INFANTRY)
  1154.     )
  1155. =>
  1156.     (release-escrow food)
  1157.     (release-escrow gold)
  1158.     (research ri-long-swordsman)
  1159. )
  1160.  
  1161. (defrule    ;300 food, 100 gold
  1162.     (can-research-with-escrow ri-two-handed-swordsman)
  1163.     (or
  1164.         (goal combat-arm INFANTRY)
  1165.         (goal combat-supp INFANTRY)
  1166.     )
  1167. =>
  1168.     (release-escrow food)
  1169.     (release-escrow gold)
  1170.     (research ri-two-handed-swordsman)
  1171. )
  1172. ;*************
  1173. ;STABLE
  1174. (defrule    ;325 food, 360 gold
  1175.     (goal upgrade-conflict NO)
  1176.     (building-type-count stable > 0)
  1177.     (unit-type-count camel > 2)
  1178.     (research-available ri-heavy-camel)
  1179.     (random-number <= 15)
  1180. =>
  1181.     (set-goal upgrade-conflict 15)
  1182.     (set-goal resource-supp FOOD-GOLD)
  1183. )
  1184.  
  1185. (defrule
  1186.     (goal upgrade-conflict 15)
  1187.     (can-research-with-escrow ri-heavy-camel)
  1188. =>
  1189.     (release-escrow food)
  1190.     (release-escrow gold)
  1191.     (research ri-heavy-camel)
  1192.     (set-goal upgrade-conflict NO)
  1193. )
  1194.  
  1195. (defrule    ;300 food, 300 gold
  1196.     (can-research-with-escrow ri-cavalier)
  1197.     (or
  1198.         (goal combat-arm CAVALRY)
  1199.         (goal combat-supp CAVALRY)
  1200.     )
  1201. =>
  1202.     (release-escrow food)
  1203.     (release-escrow gold)
  1204.     (research ri-cavalier)
  1205. )
  1206.  
  1207. (defrule    ;1300 food, 750 gold
  1208.     (goal upgrade-conflict NO)
  1209.     (random-number <= 16)
  1210.     (building-type-count stable > 0)
  1211.     (or
  1212.         (goal combat-arm CAVALRY)
  1213.         (goal combat-supp CAVALRY)
  1214.     )
  1215.     (or
  1216.         (research-available ri-paladin)
  1217.         (research-available ri-cavalier)
  1218.     )
  1219. =>
  1220.     (set-goal upgrade-conflict 16)
  1221.     (set-goal resource-supp FOOD-GOLD)
  1222. )
  1223.  
  1224. (defrule
  1225.     (goal upgrade-conflict 16)
  1226.     (or
  1227.         (can-research-with-escrow ri-cavalier)
  1228.         (can-research-with-escrow ri-paladin)
  1229.     )
  1230. =>
  1231.     (release-escrow food)
  1232.     (release-escrow gold)
  1233.     (research ri-cavalier)
  1234.     (research ri-paladin)
  1235.     (set-goal upgrade-conflict NO)
  1236. )
  1237.  
  1238. (defrule    ;250 food
  1239.     (goal upgrade-conflict NO)
  1240.     (building-type-count stable > 0)
  1241.     (research-available ri-husbandry)
  1242.     (random-number <= 17)
  1243.     (or
  1244.         (or
  1245.             (goal cav-upgrades YES)
  1246.             (goal combat-arm CAVARCHER)
  1247.         )
  1248.         (or
  1249.             (goal combat-supp CAVARCHER)
  1250.             (or
  1251.                 (civ-selected mongol)
  1252.                 (civ-selected spanish)
  1253.             )
  1254.         )
  1255.     )
  1256. =>
  1257.     (set-goal upgrade-conflict 17)
  1258.     (set-goal resource-supp FOOD-ONLY)
  1259. )
  1260.  
  1261. (defrule
  1262.     (goal upgrade-conflict 17)
  1263.     (can-research-with-escrow ri-husbandry)
  1264. =>
  1265.     (release-escrow food)
  1266.     (research ri-husbandry)
  1267.     (set-goal upgrade-conflict NO)
  1268. )
  1269.  
  1270. (defrule    ; food, gold
  1271.     (goal upgrade-conflict NO)
  1272.     (building-type-count stable > 0)
  1273.     (research-available ri-bloodlines)
  1274.     (random-number <= 18)
  1275.     (or
  1276.         (or
  1277.             (goal cav-upgrades YES)
  1278.             (goal combat-arm CAVARCHER)
  1279.         )
  1280.         (or
  1281.             (goal combat-supp CAVARCHER)
  1282.             (unit-type-count-total camel-line > 4)
  1283.         )
  1284.     )
  1285.     (not (goal rush-control CASTLE) )
  1286. =>
  1287.     (set-goal upgrade-conflict 18)
  1288.     (set-goal resource-supp FOOD-GOLD)
  1289. )
  1290.  
  1291. (defrule    ; food, gold
  1292.     (goal upgrade-conflict NO)
  1293.     (building-type-count stable > 0)
  1294.     (research-available ri-bloodlines)
  1295.     (random-number <= 18)
  1296.     (or
  1297.         (civ-selected saracen)
  1298.         (or
  1299.             (civ-selected mongol)
  1300.             (civ-selected spanish)
  1301.         )
  1302.     )
  1303.     (not (goal rush-control CASTLE) )
  1304. =>
  1305.     (set-goal upgrade-conflict 18)
  1306.     (set-goal resource-supp FOOD-GOLD)
  1307. )
  1308.  
  1309. (defrule
  1310.     (goal upgrade-conflict 18)
  1311.     (can-research-with-escrow ri-bloodlines)
  1312. =>
  1313.     (release-escrow food)
  1314.     (release-escrow gold)
  1315.     (research ri-bloodlines)
  1316.     (set-goal upgrade-conflict NO)
  1317. )
  1318.  
  1319. (defrule    ;150 food, 50 gold
  1320.     (can-research-with-escrow ri-light-cavalry)
  1321.     (not (goal rush-control IMPERIAL) )
  1322.     (or
  1323.         (or
  1324.             (goal combat-arm LIGHTCAV)
  1325.             (goal combat-supp LIGHTCAV)
  1326.         )
  1327.         (unit-type-count-total scout-cavalry > 2)
  1328.     )
  1329.     (or
  1330.         (goal upgrade-conflict NO)
  1331.         (current-age == imperial-age)
  1332.     )
  1333. =>
  1334.     (release-escrow food)
  1335.     (release-escrow gold)
  1336.     (research ri-light-cavalry)
  1337. )
  1338.  
  1339. (defrule    ;lotsa food, lotsa gold
  1340.     (goal upgrade-conflict NO)
  1341.     (building-type-count stable > 0)
  1342.     (random-number <= 19)
  1343.     (can-research-with-escrow ri-hussar)
  1344.     (or
  1345.         (or
  1346.             (goal combat-arm LIGHTCAV)
  1347.             (goal combat-supp LIGHTCAV)
  1348.         )
  1349.         (unit-type-count-total light-cavalry > 6)
  1350.     )
  1351. =>
  1352.     (set-goal upgrade-conflict 19)
  1353.     (set-goal resource-supp FOOD-GOLD)
  1354. )
  1355.  
  1356. (defrule
  1357.     (goal upgrade-conflict 19)
  1358.     (can-research-with-escrow ri-hussar)
  1359. =>
  1360.     (release-escrow food)
  1361.     (release-escrow gold)
  1362.     (research ri-hussar)
  1363.     (set-goal upgrade-conflict NO)
  1364. )
  1365.  
  1366.  
  1367. ;*************
  1368. ;ARCHERY RANGE
  1369. (defrule    ;350 food, 300 gold
  1370.     (goal upgrade-conflict NO)
  1371.     (building-type-count archery-range > 0)
  1372.     (research-available ri-arbalest)
  1373.     (random-number <= 20)
  1374.     (nor
  1375.         (research-available ri-hand-cannon)
  1376.         (research-completed ri-hand-cannon)
  1377.     )
  1378.     (or
  1379.         (goal combat-arm ARCHER)
  1380.         (goal combat-supp ARCHER)
  1381.     )
  1382. =>
  1383.     (set-goal upgrade-conflict 20)
  1384.     (set-goal resource-supp FOOD-GOLD)
  1385. )
  1386.  
  1387. (defrule
  1388.     (goal upgrade-conflict 20)
  1389.     (can-research-with-escrow ri-arbalest)
  1390. =>
  1391.     (release-escrow food)
  1392.     (release-escrow gold)
  1393.     (research ri-arbalest)
  1394.     (set-goal upgrade-conflict NO)
  1395. )
  1396.  
  1397. (defrule
  1398.     (goal upgrade-conflict 20)
  1399.     (research-completed ri-hand-cannon)
  1400. =>
  1401.     (set-goal upgrade-conflict NO)
  1402. )
  1403.  
  1404. (defrule    ;450 food, 200 gold
  1405.     (can-research-with-escrow ri-hand-cannon)
  1406. =>
  1407.     (release-escrow food)
  1408.     (release-escrow gold)
  1409.     (research ri-hand-cannon)
  1410. )
  1411.  
  1412. (defrule    ;900 food, 500 gold
  1413.     (goal upgrade-conflict NO)
  1414.     (goal combat-arm CAVARCHER)
  1415.     (building-type-count archery-range > 0)
  1416.     (research-available ri-heavy-cavalry-archer)
  1417.     (random-number <= 21)
  1418. =>
  1419.     (set-goal upgrade-conflict 21)
  1420.     (set-goal resource-supp FOOD-GOLD)
  1421. )
  1422.  
  1423. (defrule
  1424.     (goal upgrade-conflict 21)
  1425.     (can-research-with-escrow ri-heavy-cavalry-archer)
  1426. =>
  1427.     (release-escrow food)
  1428.     (release-escrow gold)
  1429.     (research ri-heavy-cavalry-archer)
  1430.     (set-goal upgrade-conflict NO)
  1431. )
  1432.  
  1433. (defrule    ;250 wood, 160 gold
  1434.     (unit-type-count skirmisher > 2)
  1435.     (can-research-with-escrow ri-elite-skirmisher)
  1436.     (or
  1437.         (goal upgrade-conflict NO)
  1438.         (current-age-time > 300)
  1439.     )
  1440.     (not (goal rush-control IMPERIAL) )
  1441. =>
  1442.     (release-escrow wood)
  1443.     (release-escrow gold)
  1444.     (research ri-elite-skirmisher)
  1445. )
  1446.  
  1447. (defrule    ;125 food, 75 gold
  1448.     (research-available ri-crossbow)
  1449.     (nor
  1450.         (research-available ri-hand-cannon)
  1451.         (or
  1452.             (research-completed ri-hand-cannon)
  1453.             (goal rush-control IMPERIAL)
  1454.         )
  1455.     )
  1456.     (or
  1457.         (goal combat-arm ARCHER)
  1458.         (or
  1459.             (goal combat-supp ARCHER)
  1460.             (goal pre-unique-arm ARCHER)
  1461.         )
  1462.     )
  1463. =>
  1464.     (release-escrow food)
  1465.     (release-escrow gold)
  1466.     (research ri-crossbow)
  1467. )
  1468.  
  1469. (defrule    ;350 wood, 250 gold
  1470.     (goal upgrade-conflict NO)
  1471.     (random-number <= 22)
  1472.     (difficulty <= hard)
  1473.     (building-type-count blacksmith > 0)
  1474.     (research-available ri-thumb-ring)
  1475.     (goal archer-upgrades YES)
  1476. =>
  1477.     (set-goal upgrade-conflict 22)
  1478.     (set-goal resource-supp WOOD-GOLD)
  1479. )
  1480.  
  1481. (defrule
  1482.     (goal upgrade-conflict 22)
  1483.     (can-research-with-escrow ri-thumb-ring)
  1484. =>
  1485.     (release-escrow wood)
  1486.     (release-escrow gold)
  1487.     (research ri-thumb-ring)
  1488.     (set-goal upgrade-conflict NO)
  1489. )
  1490.  
  1491. (defrule    ;400 food, 250 gold
  1492.     (goal upgrade-conflict NO)
  1493.     (random-number <= 23)
  1494.     (research-available ri-parthian-tactics)
  1495.     (research-completed ri-leather-archer-armor)
  1496.     (not (research-available ri-ring-archer-armor) )
  1497.     (or
  1498.         (or
  1499.             (goal combat-arm CAVARCHER)
  1500.             (goal combat-supp CAVARCHER)
  1501.         )
  1502.         (and
  1503.             (civ-selected mongol)
  1504.             (goal combat-arm UNIQUE)
  1505.         )
  1506.     )
  1507. =>
  1508.     (set-goal upgrade-conflict 23)
  1509.     (set-goal resource-supp FOOD-GOLD)
  1510. )
  1511.  
  1512. (defrule
  1513.     (goal upgrade-conflict 23)
  1514.     (can-research-with-escrow ri-parthian-tactics)
  1515. =>
  1516.     (release-escrow food)
  1517.     (release-escrow gold)
  1518.     (research ri-parthian-tactics)
  1519.     (set-goal upgrade-conflict NO)
  1520. )
  1521.  
  1522.  
  1523. ;*************
  1524. ;BLACKSMITH
  1525. (defrule    ;100 food
  1526.     (difficulty <= moderate)
  1527.     (goal infantry-upgrades YES)
  1528.     (can-research-with-escrow ri-scale-mail)
  1529.     (or
  1530.         (current-age > feudal-age)
  1531.         (goal age-advancement NOTICE)
  1532.     )
  1533.     (not (goal rush-control IMPERIAL) )
  1534. =>
  1535.     (release-escrow food)
  1536.     (research ri-scale-mail)
  1537. )
  1538.  
  1539. (defrule    ;200 food, 100 gold
  1540.     (difficulty <= moderate)
  1541.     (goal infantry-upgrades YES)
  1542.     (can-research-with-escrow ri-chain-mail)
  1543.     (or
  1544.         (goal upgrade-conflict NO)
  1545.         (or
  1546.             (current-age-time > 300)
  1547.             (goal age-advancement NOTICE)
  1548.         )
  1549.     )
  1550. =>
  1551.     (release-escrow food)
  1552.     (release-escrow gold)
  1553.     (research ri-chain-mail)
  1554. )
  1555.  
  1556. (defrule    ;300 food, 150 gold
  1557.     (goal upgrade-conflict NO)
  1558.     (random-number <= 24)
  1559.     (difficulty <= hard)
  1560.     (goal infantry-upgrades YES)
  1561.     (building-type-count blacksmith > 0)
  1562.     (research-available ri-plate-mail)
  1563. =>
  1564.     (set-goal upgrade-conflict 24)
  1565.     (set-goal resource-supp FOOD-GOLD)
  1566. )
  1567.  
  1568. (defrule
  1569.     (goal upgrade-conflict 24)
  1570.     (can-research-with-escrow ri-plate-mail)
  1571. =>
  1572.     (release-escrow food)
  1573.     (release-escrow gold)
  1574.     (research ri-plate-mail)
  1575.     (set-goal upgrade-conflict NO)
  1576. )
  1577.  
  1578. (defrule    ;150 food
  1579.     (difficulty <= moderate)
  1580.     (goal cav-upgrades YES)
  1581.     (can-research-with-escrow ri-scale-barding)
  1582.     (or
  1583.         (current-age > feudal-age)
  1584.         (goal age-advancement NOTICE)
  1585.     )
  1586.     (not (goal rush-control IMPERIAL) )
  1587. =>
  1588.     (release-escrow food)
  1589.     (research ri-scale-barding)
  1590. )
  1591.  
  1592. (defrule    ;250 food, 150 gold
  1593.     (difficulty <= moderate)
  1594.     (goal cav-upgrades YES)
  1595.     (can-research-with-escrow ri-chain-barding)
  1596.     (or
  1597.         (goal upgrade-conflict NO)
  1598.         (or
  1599.             (current-age-time > 300)
  1600.             (goal age-advancement NOTICE)
  1601.         )
  1602.     )
  1603. =>
  1604.     (release-escrow food)
  1605.     (release-escrow gold)
  1606.     (research ri-chain-barding)
  1607. )
  1608.  
  1609. (defrule    ;350 food, 200 gold
  1610.     (goal upgrade-conflict NO)
  1611.     (random-number <= 25)
  1612.     (difficulty <= hard)
  1613.     (goal cav-upgrades YES)
  1614.     (building-type-count blacksmith > 0)
  1615.     (research-available ri-plate-barding)
  1616. =>
  1617.     (set-goal upgrade-conflict 25)
  1618.     (set-goal resource-supp FOOD-GOLD)
  1619. )
  1620.  
  1621. (defrule
  1622.     (goal upgrade-conflict 25)
  1623.     (can-research-with-escrow ri-plate-barding)
  1624. =>
  1625.     (release-escrow food)
  1626.     (release-escrow gold)
  1627.     (research ri-plate-barding)
  1628.     (set-goal upgrade-conflict NO)
  1629. )
  1630.  
  1631. (defrule    ;100 food
  1632.     (difficulty <= moderate)
  1633.     (goal archer-upgrades YES)
  1634.     (can-research-with-escrow ri-padded-archer-armor)
  1635.     (or
  1636.         (current-age > feudal-age)
  1637.         (goal age-advancement NOTICE)
  1638.     )
  1639.     (not (goal rush-control IMPERIAL) )
  1640. =>
  1641.     (release-escrow food)
  1642.     (research ri-padded-archer-armor)
  1643. )
  1644.  
  1645. (defrule    ;150 food, 150 gold
  1646.     (difficulty <= moderate)
  1647.     (goal archer-upgrades YES)
  1648.     (can-research-with-escrow ri-leather-archer-armor)
  1649.     (or
  1650.         (goal upgrade-conflict NO)
  1651.         (or
  1652.             (current-age-time > 300)
  1653.             (goal age-advancement NOTICE)
  1654.         )
  1655.     )
  1656. =>
  1657.     (release-escrow food)
  1658.     (release-escrow gold)
  1659.     (research ri-leather-archer-armor)
  1660. )
  1661.  
  1662. (defrule    ;250 food, 250 gold
  1663.     (goal upgrade-conflict NO)
  1664.     (random-number <= 26)
  1665.     (difficulty <= hard)
  1666.     (goal archer-upgrades YES)
  1667.     (building-type-count blacksmith > 0)
  1668.     (research-available ri-ring-archer-armor)
  1669. =>
  1670.     (set-goal upgrade-conflict 26)
  1671.     (set-goal resource-supp FOOD-GOLD)
  1672. )
  1673.  
  1674. (defrule
  1675.     (goal upgrade-conflict 26)
  1676.     (can-research-with-escrow ri-ring-archer-armor)
  1677. =>
  1678.     (release-escrow food)
  1679.     (release-escrow gold)
  1680.     (research ri-ring-archer-armor)
  1681.     (set-goal upgrade-conflict NO)
  1682. )
  1683.  
  1684. (defrule    ;150 food
  1685.     (difficulty <= moderate)
  1686.     (can-research-with-escrow ri-forging)
  1687.     (or
  1688.         (goal infantry-upgrades YES)
  1689.         (goal cav-upgrades YES)
  1690.     )
  1691.     (or
  1692.         (current-age > feudal-age)
  1693.         (goal age-advancement NOTICE)
  1694.     )
  1695.     (not (goal rush-control IMPERIAL) )
  1696. =>
  1697.     (release-escrow food)
  1698.     (research ri-forging)
  1699. )
  1700.  
  1701. (defrule    ;220 food, 120 gold
  1702.     (difficulty <= moderate)
  1703.     (can-research-with-escrow ri-iron-casting)
  1704.     (or
  1705.         (goal infantry-upgrades YES)
  1706.         (goal cav-upgrades YES)
  1707.     )
  1708.     (or
  1709.         (goal upgrade-conflict NO)
  1710.         (or
  1711.             (current-age-time > 300)
  1712.             (goal age-advancement NOTICE)
  1713.         )
  1714.     )
  1715. =>
  1716.     (release-escrow food)
  1717.     (release-escrow gold)
  1718.     (research ri-iron-casting)
  1719. )
  1720.  
  1721. (defrule    ;275 food, 225 gold
  1722.     (goal upgrade-conflict NO)
  1723.     (random-number <= 27)
  1724.     (difficulty <= hard)
  1725.     (building-type-count blacksmith > 0)
  1726.     (research-available ri-blast-furnace)
  1727.     (or
  1728.         (goal infantry-upgrades YES)
  1729.         (goal cav-upgrades YES)
  1730.     )
  1731. =>
  1732.     (set-goal upgrade-conflict 27)
  1733.     (set-goal resource-supp FOOD-GOLD)
  1734. )
  1735.  
  1736. (defrule
  1737.     (goal upgrade-conflict 27)
  1738.     (can-research-with-escrow ri-blast-furnace)
  1739. =>
  1740.     (release-escrow food)
  1741.     (release-escrow gold)
  1742.     (research ri-blast-furnace)
  1743.     (set-goal upgrade-conflict NO)
  1744. )
  1745.  
  1746. (defrule    ;100 food, 50 gold
  1747.     (difficulty <= moderate)
  1748.     (can-research-with-escrow ri-fletching)
  1749.     (or
  1750.         (goal archer-upgrades YES)
  1751.         (or
  1752.             (unit-type-count galley-line > five-percent-pop)
  1753.             (building-type-count watch-tower-line > five-percent-pop)
  1754.         )
  1755.     )
  1756.     (or
  1757.         (current-age > feudal-age)
  1758.         (goal age-advancement NOTICE)
  1759.     )
  1760.     (not (goal rush-control IMPERIAL) )
  1761. =>
  1762.     (release-escrow food)
  1763.     (release-escrow gold)
  1764.     (research ri-fletching)
  1765. )
  1766.  
  1767. (defrule    ;200 food, 100 gold
  1768.     (can-research-with-escrow ri-bodkin-arrow)
  1769.     (or
  1770.         (goal archer-upgrades YES)
  1771.         (or
  1772.             (unit-type-count galley-line > five-percent-pop)
  1773.             (building-type-count watch-tower-line > five-percent-pop)
  1774.         )
  1775.     )
  1776.     (or
  1777.         (goal upgrade-conflict NO)
  1778.         (or
  1779.             (current-age-time > 300)
  1780.             (goal age-advancement NOTICE)
  1781.         )
  1782.     )
  1783. =>
  1784.     (release-escrow food)
  1785.     (release-escrow gold)
  1786.     (research ri-bodkin-arrow)
  1787. )
  1788.  
  1789. (defrule    ;300 food, 200 gold
  1790.     (goal upgrade-conflict NO)
  1791.     (random-number <= 28)
  1792.     (difficulty <= hard)
  1793.     (building-type-count blacksmith > 0)
  1794.     (research-available ri-bracer)
  1795.     (or
  1796.         (goal archer-upgrades YES)
  1797.         (or
  1798.             (unit-type-count galley-line > five-percent-pop)
  1799.             (building-type-count watch-tower-line > five-percent-pop)
  1800.         )
  1801.     )
  1802. =>
  1803.     (set-goal upgrade-conflict 28)
  1804.     (set-goal resource-supp FOOD-GOLD)
  1805. )
  1806.  
  1807. (defrule
  1808.     (goal upgrade-conflict 28)
  1809.     (can-research-with-escrow ri-bracer)
  1810. =>
  1811.     (release-escrow food)
  1812.     (release-escrow gold)
  1813.     (research ri-bracer)
  1814.     (set-goal upgrade-conflict NO)
  1815. )
  1816.  
  1817.  
  1818. ;*************
  1819. ;SIEGE-WORKSHOP
  1820. (defrule    ;1100 wood, 1000 food
  1821.     (goal upgrade-conflict NO)
  1822.     (goal combat-supp SCORPION)
  1823.     (difficulty <= moderate)
  1824.     (random-number <= 29)
  1825.     (building-type-count siege-workshop > 0)
  1826.     (research-available ri-heavy-scorpion)
  1827. =>
  1828.     (set-goal upgrade-conflict 29)
  1829.     (set-goal resource-supp WOOD-FOOD)
  1830. )
  1831.  
  1832. (defrule
  1833.     (goal upgrade-conflict 29)
  1834.     (can-research-with-escrow ri-heavy-scorpion)
  1835. =>
  1836.     (release-escrow wood)
  1837.     (release-escrow food)
  1838.     (research ri-heavy-scorpion)
  1839.     (set-goal upgrade-conflict NO)
  1840. )
  1841.  
  1842. (defrule
  1843.     (goal upgrade-conflict 29)
  1844.     (not (goal combat-supp SCORPION) )
  1845. =>
  1846.     (set-goal upgrade-conflict NO)
  1847. )
  1848.  
  1849. (defrule    ;300 food, 250 gold
  1850.     (goal upgrade-conflict NO)
  1851.     (difficulty <= moderate)
  1852.     (random-number <= 30)
  1853.     (building-type-count siege-workshop > 0)
  1854.     (research-available ri-capped-ram)
  1855.     (or
  1856.         (unit-type-count militiaman-line > 0)
  1857.         (unit-type-count spearman-line > 0)
  1858.     )
  1859. =>
  1860.     (set-goal upgrade-conflict 30)
  1861.     (set-goal resource-supp FOOD-GOLD)
  1862. )
  1863.  
  1864. (defrule    ;1000 food, 800 gold
  1865.     (goal upgrade-conflict NO)
  1866.     (difficulty <= moderate)
  1867.     (random-number <= 30)
  1868.     (building-type-count siege-workshop > 0)
  1869.     (unit-type-count-total capped-ram > 1)
  1870.     (research-available ri-siege-ram)
  1871.     (nor 
  1872.         (research-completed ri-bombard-cannon)
  1873.         (research-completed ri-siege-onager)
  1874.     )
  1875.     (or
  1876.         (unit-type-count militiaman-line > 0)
  1877.         (unit-type-count spearman-line > 0)
  1878.     )
  1879. =>
  1880.     (set-goal upgrade-conflict 30)
  1881.     (set-goal resource-supp FOOD-GOLD)
  1882. )
  1883.  
  1884. (defrule
  1885.     (goal upgrade-conflict 30)
  1886.     (or
  1887.         (can-research-with-escrow ri-capped-ram)
  1888.         (can-research-with-escrow ri-siege-ram)
  1889.     )
  1890. =>
  1891.     (release-escrow food)
  1892.     (release-escrow gold)
  1893.     (research ri-capped-ram)
  1894.     (research ri-siege-ram)
  1895.     (set-goal upgrade-conflict NO)
  1896. )
  1897.  
  1898. (defrule    ;800 food, 500 gold
  1899.     (goal upgrade-conflict NO)
  1900.     (difficulty <= moderate)
  1901.     (random-number <= 31)
  1902.     (building-type-count siege-workshop > 0)
  1903.     (research-available ri-onager)
  1904. =>
  1905.     (set-goal upgrade-conflict 31)
  1906.     (set-goal resource-supp FOOD-GOLD)
  1907. )
  1908.  
  1909. (defrule    ;1450 food, 1000 gold
  1910.     (goal upgrade-conflict NO)
  1911.     (difficulty <= moderate)
  1912.     (random-number <= 31)
  1913.     (unit-type-count-total onager > 1)
  1914.     (building-type-count siege-workshop > 0)
  1915.     (research-available ri-siege-onager)
  1916.     (nor
  1917.         (research-completed ri-bombard-cannon)
  1918.         (research-completed ri-siege-ram)
  1919.     )
  1920. =>
  1921.     (set-goal upgrade-conflict 31)
  1922.     (set-goal resource-supp FOOD-GOLD)
  1923. )
  1924.  
  1925. (defrule
  1926.     (goal upgrade-conflict 31)
  1927.     (or
  1928.         (can-research-with-escrow ri-onager)
  1929.         (can-research-with-escrow ri-siege-onager)
  1930.     )
  1931. =>
  1932.     (release-escrow food)
  1933.     (release-escrow gold)
  1934.     (research ri-onager)
  1935.     (research ri-siege-onager)
  1936.     (set-goal upgrade-conflict NO)
  1937. )
  1938.  
  1939. (defrule    ;500 food, 250 gold
  1940.     (difficulty <= moderate)
  1941.     (can-research-with-escrow ri-bombard-cannon)
  1942. =>
  1943.     (release-escrow food)
  1944.     (release-escrow gold)
  1945.     (research ri-bombard-cannon)
  1946. )
  1947.  
  1948. (defrule    ;600 wood, 500 food
  1949.     (goal upgrade-conflict NO)
  1950.     (difficulty <= moderate)
  1951.     (random-number <= 32)
  1952.     (building-type-count siege-workshop > 0)
  1953.     (research-available ri-siege-engineers)
  1954.     (or
  1955.         (or
  1956.             (unit-type-count battering-ram-line > 1)
  1957.             (unit-type-count mangonel-line > 1)
  1958.         )
  1959.         (or
  1960.             (unit-type-count bombard-cannon > 1)
  1961.             (unit-type-count trebuchet > 0)
  1962.         )
  1963.     )
  1964. =>
  1965.     (set-goal upgrade-conflict 32)
  1966.     (set-goal resource-supp WOOD-FOOD)
  1967. )
  1968.  
  1969. (defrule
  1970.     (goal upgrade-conflict 32)
  1971.     (can-research-with-escrow ri-siege-engineers)
  1972. =>
  1973.     (release-escrow wood)
  1974.     (release-escrow food)
  1975.     (research ri-siege-engineers)
  1976.     (set-goal upgrade-conflict NO)
  1977. )
  1978.  
  1979. ;*************
  1980. ;monastery
  1981. (defrule    ;475 gold
  1982.     (goal upgrade-conflict NO)
  1983.     (goal monk-rating GOOD)
  1984.     (building-type-count monastery > 0)
  1985.     (unit-type-count-total monk > 2)
  1986.     (research-available ri-redemption)
  1987.     (random-number <= 33)
  1988. =>
  1989.     (set-goal upgrade-conflict 33)
  1990.     (set-goal resource-supp GOLD-ONLY)
  1991. )
  1992.  
  1993. (defrule
  1994.     (goal upgrade-conflict 33)
  1995.     (can-research-with-escrow ri-redemption)
  1996. =>
  1997.     (release-escrow gold)
  1998.     (research ri-redemption)
  1999.     (set-goal upgrade-conflict NO)
  2000. )
  2001.  
  2002. (defrule    ;325 gold
  2003.     (goal upgrade-conflict NO)
  2004.     (goal monk-rating GOOD)
  2005.     (cc-players-unit-type-count any-enemy monk > 2)
  2006.     (building-type-count monastery > 0)
  2007.     (unit-type-count-total monk > 1)
  2008.     (research-available ri-atonement)
  2009.     (random-number <= 34)
  2010. =>
  2011.     (set-goal upgrade-conflict 34)
  2012.     (set-goal resource-supp GOLD-ONLY)
  2013. )
  2014.  
  2015. (defrule
  2016.     (goal upgrade-conflict 34)
  2017.     (can-research-with-escrow ri-atonement)
  2018. =>
  2019.     (release-escrow gold)
  2020.     (research ri-atonement)
  2021.     (set-goal upgrade-conflict NO)
  2022.     (set-goal resource-supp GOLD-ONLY)
  2023. )
  2024.  
  2025. (defrule    ;200 gold
  2026.     (goal upgrade-conflict NO)
  2027.     (goal monk-rating GOOD)
  2028.     (building-type-count monastery > 0)
  2029.     (unit-type-count-total monk > 1)
  2030.     (research-available ri-block-printing)
  2031.     (random-number <= 35)
  2032. =>
  2033.     (set-goal upgrade-conflict 35)
  2034.     (set-goal resource-supp GOLD-ONLY)
  2035. )
  2036.  
  2037. (defrule
  2038.     (goal upgrade-conflict 35)
  2039.     (can-research-with-escrow ri-block-printing)
  2040. =>
  2041.     (release-escrow gold)
  2042.     (research ri-block-printing)
  2043.     (set-goal upgrade-conflict NO)
  2044. )
  2045.  
  2046. (defrule    ;140 gold
  2047.     (goal upgrade-conflict NO)
  2048.     (building-type-count monastery > 0)
  2049.     (unit-type-count-total monk > 0)
  2050.     (research-available ri-fervor)
  2051.     (random-number <= 36)
  2052.     (or
  2053.         (goal monk-rating GOOD)
  2054.         (goal monk-rating FAIR)
  2055.     )
  2056. =>
  2057.     (set-goal upgrade-conflict 36)
  2058.     (set-goal resource-supp GOLD-ONLY)
  2059. )
  2060.  
  2061. (defrule
  2062.     (goal upgrade-conflict 36)
  2063.     (can-research-with-escrow ri-fervor)
  2064. =>
  2065.     (release-escrow gold)
  2066.     (research ri-fervor)
  2067.     (set-goal upgrade-conflict NO)
  2068. )
  2069.  
  2070. (defrule    ;120 gold
  2071.     (goal upgrade-conflict NO)
  2072.     (building-type-count monastery > 0)
  2073.     (unit-type-count-total monk > 0)
  2074.     (research-available ri-illumination)
  2075.     (random-number <= 37)
  2076.     (or
  2077.         (goal monk-rating GOOD)
  2078.         (goal monk-rating FAIR)
  2079.     )
  2080. =>
  2081.     (set-goal upgrade-conflict 37)
  2082.     (set-goal resource-supp GOLD-ONLY)
  2083. )
  2084.  
  2085. (defrule
  2086.     (goal upgrade-conflict 37)
  2087.     (can-research-with-escrow ri-illumination)
  2088. =>
  2089.     (release-escrow gold)
  2090.     (research ri-illumination)
  2091.     (set-goal upgrade-conflict NO)
  2092. )
  2093.  
  2094. (defrule    ;120 gold
  2095.     (goal upgrade-conflict NO)
  2096.     (building-type-count monastery > 0)
  2097.     (unit-type-count-total monk > 0)
  2098.     (research-available ri-sanctity)
  2099.     (random-number <= 38)
  2100.     (or
  2101.         (goal monk-rating GOOD)
  2102.         (goal monk-rating FAIR)
  2103.     )
  2104. =>
  2105.     (set-goal upgrade-conflict 38)
  2106.     (set-goal resource-supp GOLD-ONLY)
  2107. )
  2108.  
  2109. (defrule
  2110.     (goal upgrade-conflict 38)
  2111.     (can-research-with-escrow ri-sanctity)
  2112. =>
  2113.     (release-escrow gold)
  2114.     (research ri-sanctity)
  2115.     (set-goal upgrade-conflict NO)
  2116. )
  2117.  
  2118. (defrule    ;1000 gold
  2119.     (goal upgrade-conflict NO)
  2120.     (random-number <= 39)
  2121.     (cc-players-unit-type-count any-enemy monk > 3)
  2122.     (building-type-count monastery > 0)
  2123.     (research-available ri-heresy)
  2124.     (or
  2125.         (not (research-completed ri-faith) )
  2126.         (cc-players-unit-type-count any-enemy monk > 6)
  2127.     )
  2128. =>
  2129.     (set-goal upgrade-conflict 39)
  2130.     (set-goal resource-supp GOLD-ONLY)
  2131. )
  2132.  
  2133. (defrule
  2134.     (goal upgrade-conflict 39)
  2135.     (can-research-with-escrow ri-heresy)
  2136. =>
  2137.     (release-escrow gold)
  2138.     (research ri-heresy)
  2139.     (set-goal upgrade-conflict NO)
  2140. )
  2141.  
  2142. (defrule    ;750 food, 1000 gold
  2143.     (goal upgrade-conflict NO)
  2144.     (random-number <= 40)
  2145.     (cc-players-unit-type-count any-enemy monk > 3)
  2146.     (building-type-count monastery > 0)
  2147.     (research-available ri-faith)
  2148.     (or
  2149.         (not (research-completed ri-heresy) )
  2150.         (cc-players-unit-type-count any-enemy monk > 6)
  2151.     )
  2152. =>
  2153.     (set-goal upgrade-conflict 40)
  2154.     (set-goal resource-supp FOOD-GOLD)
  2155. )
  2156.  
  2157. (defrule
  2158.     (goal upgrade-conflict 40)
  2159.     (can-research-with-escrow ri-faith)
  2160. =>
  2161.     (release-escrow food)
  2162.     (release-escrow gold)
  2163.     (research ri-faith)
  2164.     (set-goal upgrade-conflict NO)
  2165. )
  2166.  
  2167. ;*************
  2168. ;UNIVERSITY
  2169. (defrule    ;175 wood, 150 stone
  2170.     (goal upgrade-conflict NO)
  2171.     (random-number <= 41)
  2172.     (building-type-count university > 0)
  2173.     (research-available ri-masonry)
  2174. =>
  2175.     (set-goal upgrade-conflict 41)
  2176.     (set-goal resource-supp WOOD-STONE)
  2177. )
  2178.  
  2179. (defrule    ;200 wood, 300 stone
  2180.     (goal upgrade-conflict NO)
  2181.     (random-number <= 41)
  2182.     (building-type-count university > 0)
  2183.     (research-available ri-architecture)
  2184.     (not (goal wonder-attempt POSSIBLE) )
  2185. =>
  2186.     (set-goal upgrade-conflict 35)
  2187.     (set-goal resource-supp WOOD-STONE)
  2188. )
  2189.  
  2190. (defrule
  2191.     (goal upgrade-conflict 41)
  2192.     (or
  2193.         (can-research-with-escrow ri-masonry)
  2194.         (can-research-with-escrow ri-architecture)
  2195.     )
  2196. =>
  2197.     (release-escrow wood)
  2198.     (release-escrow stone)
  2199.     (research ri-masonry)
  2200.     (research ri-architecture)
  2201.     (set-goal upgrade-conflict NO)
  2202. )
  2203.  
  2204. (defrule    ;200 wood, 300 stone
  2205.     (goal upgrade-conflict NO)
  2206.     (random-number <= 42)
  2207.     (building-type-count university > 0)
  2208.     (research-available ri-stonecutting)
  2209.     (not (goal wonder-attempt POSSIBLE) )
  2210. =>
  2211.     (set-goal upgrade-conflict 42)
  2212.     (set-goal resource-supp WOOD-STONE)
  2213. )
  2214.  
  2215. (defrule
  2216.     (goal upgrade-conflict 42)
  2217.     (can-research-with-escrow ri-stonecutting)
  2218. =>
  2219.     (release-escrow wood)
  2220.     (release-escrow stone)
  2221.     (research ri-stonecutting)
  2222.     (set-goal upgrade-conflict NO)
  2223. )
  2224.  
  2225. (defrule    ;100 food, 250 stone
  2226.     (building-type-count watch-tower > 2)
  2227.     (can-research-with-escrow ri-guard-tower)
  2228.     (or
  2229.         (goal upgrade-conflict NO)
  2230.         (current-age-time > 600)
  2231.     )
  2232. =>
  2233.     (release-escrow food)
  2234.     (release-escrow stone)
  2235.     (research ri-guard-tower)
  2236. )
  2237.  
  2238. (defrule    ;500 food, 350 stone
  2239.     (goal upgrade-conflict NO)
  2240.     (random-number <= 43)
  2241.     (building-type-count university > 0)
  2242.     (building-type-count guard-tower > 0)
  2243.     (research-available ri-keep)
  2244. =>
  2245.     (set-goal upgrade-conflict 43)
  2246.     (set-goal resource-supp FOOD-STONE)
  2247. )
  2248.  
  2249. (defrule
  2250.     (goal upgrade-conflict 43)
  2251.     (can-research-with-escrow ri-keep)
  2252. =>
  2253.     (release-escrow food)
  2254.     (release-escrow stone)
  2255.     (research ri-keep)
  2256.     (set-goal upgrade-conflict NO)
  2257. )
  2258.  
  2259. (defrule    ;800 food, 400 stone
  2260.     (goal upgrade-conflict NO)
  2261.     (random-number <= 44)
  2262.     (building-type-count university > 0)
  2263.     (building-type-count watch-tower-line > 2)
  2264.     (research-available ri-bombard-tower)
  2265. =>
  2266.     (set-goal upgrade-conflict 44)
  2267.     (set-goal resource-supp FOOD-STONE)
  2268. )
  2269.  
  2270. (defrule
  2271.     (goal upgrade-conflict 44)
  2272.     (can-research-with-escrow ri-bombard-tower)
  2273. =>
  2274.     (release-escrow food)
  2275.     (release-escrow stone)
  2276.     (research ri-bombard-tower)
  2277.     (set-goal upgrade-conflict NO)
  2278. )
  2279.  
  2280. (defrule    ;200 food, 200 stone
  2281.     (can-research-with-escrow ri-murder-holes)
  2282.     (or
  2283.         (building-type-count watch-tower-line > 1)
  2284.         (building-type-count castle > 0)
  2285.     )
  2286. =>
  2287.     (release-escrow food)
  2288.     (release-escrow stone)
  2289.     (research ri-murder-holes)
  2290. )
  2291.  
  2292. (defrule    ;200 food, 100 stone
  2293.     (goal wall-build YES)
  2294.     (can-research-with-escrow ri-fortified-wall)
  2295. =>
  2296.     (release-escrow food)
  2297.     (release-escrow stone)
  2298.     (research ri-fortified-wall)
  2299. )
  2300.  
  2301. (defrule    ;350 food, 100 gold
  2302.     (goal upgrade-conflict NO)
  2303.     (random-number <= 45)
  2304.     (building-type-count university > 0)
  2305.     (research-available ri-heated-shot)
  2306.     (nor
  2307.         (goal 1 0)
  2308.         (goal 2 YES)
  2309.     )
  2310. =>
  2311.     (set-goal upgrade-conflict 45)
  2312.     (set-goal resource-supp FOOD-GOLD)
  2313. )
  2314.  
  2315. (defrule
  2316.     (goal upgrade-conflict 45)
  2317.     (can-research-with-escrow ri-heated-shot)
  2318. =>
  2319.     (release-escrow food)
  2320.     (release-escrow gold)
  2321.     (research ri-heated-shot)
  2322.     (set-goal upgrade-conflict NO)
  2323. )
  2324.  
  2325. (defrule    ;300 wood, 175 gold
  2326.     (goal upgrade-conflict NO)
  2327.     (random-number <= 46)
  2328.     (building-type-count university > 0)
  2329.     (research-available ri-ballistics)
  2330.     (or
  2331.         (unit-type-count galley-line >= five-percent-pop)
  2332.         (or
  2333.             (goal archer-upgrades YES)
  2334.             (research-completed ri-guard-tower)
  2335.         )
  2336.     )
  2337. =>
  2338.     (set-goal upgrade-conflict 46)
  2339.     (set-goal resource-supp WOOD-GOLD)
  2340. )
  2341.  
  2342. (defrule
  2343.     (goal upgrade-conflict 46)
  2344.     (can-research-with-escrow ri-ballistics)
  2345. =>
  2346.     (release-escrow wood)
  2347.     (release-escrow gold)
  2348.     (research ri-ballistics)
  2349.     (set-goal upgrade-conflict NO)
  2350. )
  2351.  
  2352. (defrule    ;300 food, 200 gold
  2353.     (building-type-count university > 0)
  2354.     (can-research-with-escrow ri-chemistry)
  2355. =>
  2356.     (release-escrow food)
  2357.     (release-escrow gold)
  2358.     (research ri-chemistry)
  2359. )
  2360. ;*************
  2361. ;CASTLE
  2362. (defrule    ;400 wood, 400 stone
  2363.     (goal upgrade-conflict NO)
  2364.     (random-number <= 47)
  2365.     (building-type-count castle > 0)
  2366.     (research-available ri-hoardings)
  2367.     (not (goal wonder-attempt POSSIBLE) )
  2368. =>
  2369.     (set-goal upgrade-conflict 47)
  2370.     (set-goal resource-supp WOOD-STONE)
  2371. )
  2372.  
  2373. (defrule
  2374.     (goal upgrade-conflict 47)
  2375.     (can-research-with-escrow ri-hoardings)
  2376. =>
  2377.     (release-escrow wood)
  2378.     (release-escrow stone)
  2379.     (research ri-hoardings)
  2380.     (set-goal upgrade-conflict NO)
  2381. )
  2382.  
  2383. (defrule    ;150 food, 150 gold
  2384.     (can-research-with-escrow ri-conscription)
  2385. =>
  2386.     (release-escrow food)
  2387.     (release-escrow gold)
  2388.     (research ri-conscription)
  2389. )
  2390.  
  2391.